<form id="form1" method="post">
<fieldset id="fd1" style="width:800px;">
	<legend><span>客户信息</span></legend>
	<div class="fieldset-body">
		<input name="id" id="id" class="mini-hidden" value="0"/>
		<table class="form-table" id="tableone" border="0" cellpadding="1" cellspacing="2">
			<tr>
				<td class="form-label" style="width:100px;">客户姓名:</td>
				<td style="width:200px"><input id="customer" class="mini-textbox" style="width:100%;"/></td>
				<td class="form-label" style="width:100px;">工单类型:</td>
				<td style="width:200px"><input id="types" class="mini-textbox" style="width:100%;"/></td>
				<td style="width:150px">&nbsp;</td>
			</tr>
			<tr>
				<td class="form-label">性别:</td>
				<td><input id="sex" class="mini-textbox" style="width:100%;"/></td>
				<td class="form-label">手机号:</td>
				<td><input id="mobile_phone" class="mini-textbox" style="width:100%;"/></td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td class="form-label">座机号:</td>
				<td><input id="tel" class="mini-textbox" style="width:100%;"/></td>
				<td class="form-label" >邮箱:</td>
				<td><input id="email" class="mini-textbox" style="width:100%;"/></td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td class="form-label">地址:</td>
				<td colspan="3"><input id="adders" class="mini-textbox" style="width:100%;"/></td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td >&nbsp;</td>
				<td colspan="4"><font color="red">*以下属于回访部分，请输入！</font></td>
			</tr>
			<tr>
				<td class="form-label">回访内容:</td>
				<td colspan="3"><input name="returnCon1" id="returnCon1" class="mini-textarea" emptyText="请输入回访内容" style="width:100%;"/></td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td class="form-label">评价:</td>
				<td colspan="3"><input name="returnNum" id="returnNum" class="mini-radiobuttonlist" data="[{id:1,text:'很差'},{id:2,text:'差'},{id:3,text:'一般'},{id:4,text:'满意'},{id:5,text:'很满意'}]"/></td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td class="form-label">评价内容:</td>
				<td colspan="3"><input name="returnCon2" id="returnCon2" class="mini-textarea" emptyText="请输入评价内容" style="width:100%;"/></td>
				<td><a class="mini-button" iconCls="icon-add" id="btnUpd" onclick="btnUpd()">保存回访记录</a></td>
			</tr>
		</table>
	</div>
</fieldset>
</form>
<div class="mini-toolbar" style="padding:0px;margin:6px 0px 0px 0px;border-bottom:0;">
	<table style="width:100%;">
		<tr>
			<td style="width:100%;">
				<span class="separator"></span>
				<input id="statusFlg" class="mini-combobox" textField="name" valueField="id" value="1" data="[{id:1,name:'未回访'},{id:2,name:'已回访'}]" allowInput="true" style="width:100px;"/>
				<input id="name" class="mini-textbox" emptyText="请输入标题" style="width:150px;" onenter="onKeyEnter"/>   
				<a class="mini-button" iconCls="icon-search" id="search">查询</a>
				<span class="separator"></span>
				<a class="mini-button" iconCls="icon-search" onClick="BusinessInfo('id')" plain="true">查看工单详情</a>
			</td>
		</tr>
	</table>
</div>
<div id="grid1" class="mini-datagrid" style="width:100%;height:28%;" idField="id" allowResize="false" borderStyle="border-left:0;border-right:0;" onselectionchanged="onSelectionChanged" url="/service/returnList" >
	<div property="columns">
		<div type="indexcolumn"></div>
		<div field="id" width="60" allowSort="true">工单编号</div>
		<div field="types" headerAlign="center" align="center" width="60">类型</div>
		<div field="status" headerAlign="center" align="center" width="60">状态</div>
		<div field="customer" width="80">顾客</div>
		<div field="sex" width="40" headerAlign="center" align="center">性别</div>
		<div field="mobile_phone" width="80">手机</div>
		<div field="tel" width="80">座机</div>
		<div field="email" width="80">邮箱</div>
		<div field="adders" width="100">地址</div>
		<div field="title" width="100">标题</div>
		<div field="content" width="300">内容</div>
		<div field="created" headerAlign="center" align="center" dateFormat="yyyy-MM-dd HH:mm:ss" width="130">回访时间</div>
	</div>
</div>
<script type="text/javascript">
mini.parse();

mini.get("customer").disable();
mini.get("types").disable();
mini.get("sex").disable();
mini.get("mobile_phone").disable();
mini.get("tel").disable();
mini.get("email").disable();
mini.get("adders").disable();
mini.get("btnUpd").disable();

var urlUpd="/service/inputUpd";
var form = new mini.Form("form1");
var grid = mini.get("grid1");
grid.load();

//选择
function onSelectionChanged(e) {
	var gridSelection = e.sender;
	var record = gridSelection.getSelected();
	if (record) {
		if(record.status=="已回访"){
			mini.get("returnCon1").setValue(record.content1);
			mini.get("returnCon2").setValue(record.content2);
			mini.get("returnNum").setValue(record.contentNum);
			mini.get("btnUpd").disable();
		}else{
			mini.get("returnCon1").setValue("");
			mini.get("returnCon2").setValue("");
			mini.get("returnNum").setValue(0);
			mini.get("btnUpd").enable();
		}
		mini.get("id").setValue(record.id);
		mini.get("customer").setValue(record.customer);
		mini.get("types").setValue(record.types);
		mini.get("sex").setValue(record.sex);
		mini.get("mobile_phone").setValue(record.mobile_phone);
		mini.get("tel").setValue(record.tel);
		mini.get("email").setValue(record.email);
		mini.get("adders").setValue(record.adders);
	}
}

//查询功能
$("#search").click(function(){
	grid.load({name:mini.get("name").getValue(),statusFlg:mini.get("statusFlg").getValue()});
});

//设置行样式
grid.on("drawcell", function (e) {
	if(e.column.field == "status"){
		e.cellStyle = "color:red;";
	}
});

//回访记录
function btnUpd(){
	if ($.trim(mini.get("returnCon1").getValue()) == "" || $.trim(mini.get("returnCon2").getValue()) == "" ||
		$.trim(mini.get("returnNum").getValue()) == "0" || $.trim(mini.get("returnNum").getValue()) == ""
		){
		parent.$.dooDialog.alert("输入不正确，请重新输入！");
		return;
	}

	$.post('/service/returnSave',$("#form1").serializeArray(),function(data){
		if(data.code=='OK'){
			grid.load({name:mini.get("name").getValue(),statusFlg:mini.get("statusFlg").getValue()});
		}else{
			parent.$.dooDialog.alert('回访保存失败！');
			return false;
		}
	},'json');
}
</script>
